package kioschool.view.controlsimpl
{
	import flash.display.DisplayObject;
	import flash.events.MouseEvent;
	
	import kioschool.controller.PrimaryController;
	import kioschool.view.controls.IRegimePanel;

	/**
	 * Панель управления режимами, предоставляемая платформой по умолчанию
	 * 
	 * @author Akimushkin Vasiliy
	 */ 
	public class DefaultRegimePanel implements IRegimePanel
	{
		/**
		 * Дефолтное представление
		 */ 
		private var view:DefaultRegimePanelView = new DefaultRegimePanelView();
		
		/**
		 * Конструктор, инициализирует слушателей кнопок смены режимов
		 */ 
		public function DefaultRegimePanel(){
			view.panel_mc.demo_btn.addEventListener(MouseEvent.MOUSE_DOWN, function():void{
				PrimaryController.instance.regime=PrimaryController.REGIME_DEMO;
			});
			
			view.panel_mc.train_btn.addEventListener(MouseEvent.MOUSE_DOWN, function():void{
				PrimaryController.instance.regime=PrimaryController.REGIME_TRAINING;
			});
			
			view.panel_mc.control_btn.addEventListener(MouseEvent.MOUSE_DOWN, function():void{
				PrimaryController.instance.regime=PrimaryController.REGIME_CONTROL;
			});
		}
		
		public function regimeChanged(regime:int):void{
			if(regime==PrimaryController.REGIME_DEMO)
				view.selectButton(view.panel_mc.demo_btn);
			else if(regime==PrimaryController.REGIME_TRAINING)
				view.selectButton(view.panel_mc.train_btn);
			else if(regime==PrimaryController.REGIME_CONTROL)
				view.selectButton(view.panel_mc.control_btn);
		}
		
		public function getView():DisplayObject{
			return view;
		}
	}
}